﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AopAndIocDemo.WebUI.Controllers
{
    public class TestController : Controller
    {
        // GET: Test
        public ActionResult Index()
        {
            AnimalService animal=new AnimalService();
           var s= animal.Name();

            AnimalService animal2=new BirdService();
           var s2= animal2.Name();
           //animal2.Do();//向上转型，animal2会把与子类的扩展属性和方法过滤掉；

            //BirdService bird=new AnimalService();
            //bird.Name();

            ViewBag.Msg = string.Format("{0},{1}", s, s2);

            return View();
        }
    }

    public class AnimalService
    {
        public string Name()
        {
            return "AnimalService.Name()";
        }
    }

    public class BirdService : AnimalService
    {
        public string Do()
        {
            return "BirdService.Do()";
        }
        public new string Name()
        {
            return "BirdService.Name()";
        }
    }
}